package com.mmp.main.servlet.report;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mmp.common.servlet.BasicServlet;
import com.mmp.main.entity.JobOrder;
import com.mmp.main.util.Enums;

public class ViewJobOrdersOpened extends BasicServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		JobOrder jobOrder = new JobOrder();
		jobOrder.setCancelled(false);
		jobOrder.setClosed(false);

		List<JobOrder> jOrders = dbm.find(jobOrder);
		if (jOrders == null || jOrders.isEmpty()) {
			announceErorrMessage(request, response, "لا يوجد أوامر عمل مفتوحة");
		} else {
			request.setAttribute("jobOrders", jOrders);
			viewHTMLReport(request, response, "report/ViewJobOrdersOpened.jsp", Enums.REPORT_TITLE.OPENED_JOB_ORDERS.getReportTitle());
		}
	}
}
